package com.heima.comment.controller;

import com.heima.comment.service.CommentRepayService;
import com.heima.comment.service.CommentService;
import com.heima.model.common.dtos.comment.CommentRepayDto;
import com.heima.model.common.dtos.comment.CommentRepayLikeDto;
import com.heima.model.common.dtos.comment.CommentRepaySaveDto;
import com.heima.model.common.dtos.common.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Response;

@RestController
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {
    @Autowired
    private CommentRepayService commentRepayService;

    /**
     * 保存回复的评论
     * @param commentRepaySaveDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveCommentRepay(@RequestBody CommentRepaySaveDto commentRepaySaveDto) {
        return commentRepayService.save(commentRepaySaveDto);
    }

    /**
     * 分页显示回复评论信息
     * @param commentRepayDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayDto commentRepayDto) {
        return commentRepayService.load(commentRepayDto);
    }

    /**
     * 点赞回复的评论功能
     * @param commentRepayLikeDto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult likeCommentRepay(@RequestBody CommentRepayLikeDto commentRepayLikeDto) {
        return commentRepayService.like(commentRepayLikeDto);
    }
}
